<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.wy17113.model.entity.*"%>
<%@page import="com.wy17113.model.service.*"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
			
	WebApplicationContext webContext = WebApplicationContextUtils
				.getRequiredWebApplicationContext(application);
	IUserService users = (IUserService) webContext.getBean("userService");			
	IScoreRecordService srService = (IScoreRecordService) webContext.getBean("scoreRecordService");
			
	User user = (User)session.getAttribute("user");
	int scores = users.getUserScoresById(user.getId());
	int inviteNum = (int)users.getUserinviteNum(user.getId());
	
	int sumScore = srService.getSumScoreByState(2 ,user.getId());//总积分
	int receivedScore = srService.getSumScoreByState(1 ,user.getId());//已领取积分
	int unReceiveScore = srService.getSumScoreByState(-1 ,user.getId());//未领取积分
	int cancelScore = srService.getSumScoreByState(0 ,user.getId());//作废积分	
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">

<html>
<head>
	<META http-equiv=Content-Type content="text/html; charset=utf-8">
	<title>个人中心-17113个人主页</title>
	<style type="text/css">
body {
	margin: 0px 0px 10px 0px;
	padding: 0px;
	font-size: 14px;
	line-height: 24px;
	color: #000000;
	background-color: #fbfbfb;
}

background
:url
(../img/bg
.gif
)
 
repeat
:repeat-x
;
}
.title {
	color: #000000;
	font-size: 14px;
}

td {
	text-align: left;
	padding-left: 10px;
}

A:link {
	COLOR: #3a81cd;
	TEXT-DECORATION: underline
}

A:visited {
	COLOR: #3a81cd;
	TEXT-DECORATION: underline
}

A:hover {
	COLOR: #3a81cd;
	TEXT-DECORATION: underline
}

.btn-s {
	BORDER-RIGHT: #AAD133 1px solid;
	BORDER-TOP: #AAD133 1px solid;
	FONT-WEIGHT: bold;
	BACKGROUND: #AAD133;
	BORDER-LEFT: #AAD133 1px solid;
	WIDTH: 97px;
	CURSOR: pointer;
	BORDER-BOTTOM: #AAD133 1px solid;
	HEIGHT: 32px
}

.btn-s {
	FONT-SIZE: 14px
}

.btn {
	BORDER-RIGHT: #000000 1px solid;
	BORDER-TOP: #000000 1px solid;
	FONT-WEIGHT: bold;
	BACKGROUND: #AAD133;
	BORDER-LEFT: #000000 1px solid;
	WIDTH: 185px;
	CURSOR: pointer;
	BORDER-BOTTOM: #000000 1px solid;
	HEIGHT: 32px
}

.btn {
	FONT-SIZE: 14px
}

.btn:hover {
	BACKGROUND: #c6e370
}

.btn {
	COLOR: #000000
}

.btn-s:hover {
	BACKGROUND: #c6e370
}

.btn-s {
	COLOR: #000000
}

.searchinput {
	border-right-width: 0px;
	padding-left: 3px;
	width: 168px;
	height: 20px;
	font-family: arial;
	float: left;
	border-top-width: 0px;
	border-bottom-width: 0px;
	color: #636365;
	margin-left: 4px;
	font-size: 10pt;
	vertical-align: middle;
	border-left-width: 110px;
	margin-right: 13px;
	font: 12px "宋体", arial; /*font:16px arial;*/
	height: 28px;
	line-height: 28px\9;
	_line-height: 29px;
	width: 24em;
	padding-left: 4px;
	border: 1px solid #ace;
	overflow: hidden;
	outline: none;
}
</style>
<script language="javascript">
function showScore(){
	alert("当前总积分为：<%=sumScore %>, 已兑换积分为:<%=receivedScore %> \n 已作废积分为：<%=cancelScore %>, 可用总积分为:<%=unReceiveScore %>");
}

function welcom() {
   alert("已复制");
}

function copyit(){
	var v=document.getElementById("t").value;
	window.clipboardData.setData("text",v);
	window.alert("已成功复制到剪切板!");
}

function getXmlHttp(){ 
    var http_request = false; 
    if (window.XMLHttpRequest){ 
        http_request = new XMLHttpRequest(); 
        if (http_request.overrideMimeType){ 
            http_request.overrideMimeType('text/xml'); 
	} 
   }else if (window.ActiveXObject){ 
        try{ 
            http_request = new ActiveXObject("Msxml2.XMLHTTP"); 
        } catch (e){ 
            try{ 
                http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
            }catch (e) {
            } 
        } 
    } 
    if (!http_request){ 
        alert("系统忙、请稍后再试!"); 
        return false; 
    } 
    return http_request; 
} 

function result(){ 
    if(req.readyState == 4 && req.status == 200){
    	if(req.responseText.toString() != "flase"){
    		alert("签到成功！积分 +5");
	       	document.getElementById("checkQianDao").disabled = true;
	       	document.getElementById("score_num").innerHTML = req.responseText.toString();
    	}else{
    		alert("今天已经签到、请明天再来!");
    		document.getElementById("checkQianDao").disabled = true;
    	}
    }     
} 

function checkQianDao(){	
	var ul="AjaxCheckQianDaoServlet?id=" + document.getElementById("id").value;     
	req = getXmlHttp(); 
	req.onreadystatechange = result; 
	req.open("GET",ul,true); 
	req.setRequestHeader('If-Modified-Since', '0'); 
	req.send(null); 
}

</script>

</head>
<body>
	<table width="100%" height="120" border="0" cellspacing="0"
		cellpadding="0" bgcolor="#3a81cd">
		<div style="width: 100%; height: 0; overflow: hiddne; border-top: 1px solid #D9D9D9">
		<tr>
			<td>
				<div style="margin-left: 150px;">
					<a href="http://www.17113.cc"><img src="img/logo-r.gif"
							border="0"/ >
					</a>
					<br>
					<font color="#ffffff" size="2">健康，绿色，个人网址导航</font>
				</div>
			</td>
			<td>
				<div style="margin-left: 240px;">
					<a href="http://www.17113.cc"><font color="#ffffff" size="3">首页</font></a>
					<a href="doUser.do?opers=loginOut"><font color="#ffffff" size="3">注销登陆</font></a>
				</div>
			</td>
		</tr>
	</table>
	<div
		style="width: 100%; height: 0; overflow: hiddne; border-top: 1px solid #D9D9D9"/ >
		<div style="width: 960px; margin: 0 auto;">
			<table width="960" border="0" cellspacing="5" cellpadding="0">
				<tr>
					<td width="112" class="title">
						<font color="#00" size="4"><b>个人中心：</b>
						</font>
					</td>
				</tr>
			</table>
			<table border="0" cellspacing="5" cellpadding="0">
				<tr>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</table>
			<div style="width: 960px; margin: 0 auto;">
				<table width="960" border="0" cellspacing="5" cellpadding="0">
					<div style="width: 100%; height: 0; overflow: hiddne; border-top: 1px solid #D2E9FF"/ >
						
					<tr>
						<td width="112" class="title">
							<font color="#00" size="3"><strong>帐号：</strong>
							</font>
							<br>
							<font color="#00" size="2"><%=user.getLoginAccount() %></font>
						</td>
						<td width="112" class="title">
							<font color="#00" size="3"><strong>邮箱：</strong>
							</font>
							<br>
							<font color="#00" size="2"><%=user.getEmail() %></font>
						</td>
						<td width="112" class="title">
							<a href="rule.jsp" target="_blank"><strong>查看积分规则>></strong>
							</a>
						</td>
					</tr>
				</table>
				<table border="0" cellspacing="5" cellpadding="0">
					<tr>
						<td></td>
						<td></td>
						<td></td>
					</tr>
				</table>
				<div style="width: 960px; margin: 0 auto;">
					<table width="960" border="0" cellspacing="5" cellpadding="0">
						<div style="width: 100%; height: 0; overflow: hiddne; border-top: 1px solid #D2E9FF"/ >
						<tr>
							<td>
								<input class="btn-s" id="checkQianDao" type="button" value="签到" name="checkQianDao" onclick="javascript:checkQianDao();"/>
								&nbsp;&nbsp;
								<input type="hidden" id="id" name="id" value="<%=user.getId() %>"/>
								<font color="#ff00" size="2"><strong>注意：每天签到+5分</strong></font>
							</td>
							<td>
								<font color="#00" size="3"><strong>当前可用总积分：</strong></font>
								<font color="#ff0000" size="3"><span id="score_num"><%=scores %></span></font><font>&nbsp;&nbsp;分</font>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<a href="javascript:showScore();"><strong>查看积分详情>></strong></a>
							</td>
						</tr>
					</table>
					<table border="0" cellspacing="5" cellpadding="0">
						<tr>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</table>
					<div style="width: 960px; margin: 0 auto;">
						<table width="960" border="0" cellspacing="5" cellpadding="0">
							<div style="width: 100%; height: 0; overflow: hiddne; border-top: 1px solid #D2E9FF"/ >
							
							<tr>
								<td colspan="2">
									<font color="#00" size="3"><strong>已邀好友：</strong>
									</font>
									<font color="#ff0000" size="3"><%=inviteNum %></font>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<font color="#ff00" size="2"><strong>点击“复制”发送给好友</strong></font>
								</td>
								<td colspan="2">
									<div><input type="text" disabled="true" name="q" class="searchinput" id="t" value="<%=basePath %>index.jsp?fromId=<%=user.getId() %>"><input type="submit" class="btn-s" id="word" value="复制" name="word" onclick="copyit()"> 
									</div>
									
								</td>

							</tr>
						</table>
						<table border="0" cellspacing="5" cellpadding="0">
							<tr>
								<td></td>
								<td></td>
								<td></td>
							</tr>
						</table>
						<div style="width: 960px; margin: 0 auto;">
							<table width="960" border="0" cellspacing="5" cellpadding="0">
								<div
									style="width: 100%; height: 0; overflow: hiddne; border-top: 1px solid #D2E9FF"/ >
									
								<tr>
									<td colspan="2">
										<font color="#00" size="3"><strong>发布友链:</strong>
										</font>

									</td>
									<td colspan="2">
										<input type="text" name="q" class="searchinput" id="t"
											value="http://" />
										<INPUT class=btn-s id=word type=submit value="发布" name=word" >
										<br>
									</td>
									<td width="112" class="title">
										<a href="http://www.17113.cc/flink.html" target="_blank"><strong>查看友链>></strong>
										</a>
									</td>
								</tr>
								<tr>
									<td colspan="2">
										<font color="#00" size="3"><strong>加入互踩:</strong>
										</font>

									</td>
									<td colspan="2">
										<input type="text" name="q" class="searchinput" id="t"
											value="http://" />
										<INPUT class=btn-s id=word type=submit value="发布" name=word" >
										<br>
									</td>
									<td width="112" class="title">
										<a href="http://www.17113.cc/wzhclm.html" target="_blank"><strong>查看互踩>></strong>
										</a>
									</td>
								</tr>
							</table>
							<table border="0" cellspacing="5" cellpadding="0">
								<tr>
									<td></td>
									<td></td>
									<td></td>
								</tr>
							</table>
							<div style="width: 960px; margin: 0 auto;">
								<table width="960" border="0" cellspacing="5" cellpadding="0">
									<div style="width: 100%; height: 0; overflow: hiddne; border-top: 1px solid #D2E9FF"/ >
										
									<tr>
										<td colspan="2">
											<font color="#00" size="3"><strong>积分兑换：</strong>
											</font>
											<br>
											<font color="#ff0000">联系QQ：</font>
											<a target=blank href=http://wpa.qq.com/msgrd?V=1&Uin=457429114&Site=http://www.17113.cc&Menu=yes>
											<img border="0" SRC=http://wpa.qq.com/pa?p=1:457429114:16 alt="点击这里给我发消息"></a>
										</td>

									</tr>
								</table>
								<table border="0" cellspacing="5" cellpadding="0">
									<tr>
										<td></td>
										<td></td>
										<td></td>
									</tr>
								</table>
							</div>
</body>
</html>

